home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / BlobMgr / Demo Folder / PickWord.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-05  |  9.9 KB  |  751 lines  |  [TEXT/KAHL]

  1. /*
  2.  * Blob ManagerDemo:  Random word picker
  3.  */
  4.  
  5. # include    "BlobMgr.h"
  6. # include    "BlobDemo.h"
  7.  
  8.  
  9. # define    maxWords    700
  10.  
  11.  
  12. static unsigned char    *word[] =
  13. {
  14. "\paback",
  15. "\pabalone",
  16. "\pabandon",
  17. "\pabase",
  18. "\paccent",
  19. "\paccentuate",
  20. "\paccept",
  21. "\pacerbic",
  22. "\pacrobat",
  23. "\padage",
  24. "\padagio",
  25. "\padamant",
  26. "\padapt",
  27. "\padaptation",
  28. "\paegis",
  29. "\paeolian",
  30. "\paerate",
  31. "\paerial",
  32. "\paerobic",
  33. "\pairborne",
  34. "\paircraft",
  35. "\pallied",
  36. "\palligator",
  37. "\palliterate",
  38. "\pallocate",
  39. "\pambuscade",
  40. "\pambush",
  41. "\pameliorate",
  42. "\pamen",
  43. "\pamend",
  44. "\pangelfish",
  45. "\pangelic",
  46. "\panger",
  47. "\pangiosperm",
  48. "\pangle",
  49. "\pantler",
  50. "\panvil",
  51. "\panxiety",
  52. "\panxious",
  53. "\papproximate",
  54. "\papricot",
  55. "\papron",
  56. "\papropos",
  57. "\papse",
  58. "\parrangeable",
  59. "\parray",
  60. "\parrear",
  61. "\parrest",
  62. "\parrival",
  63. "\passignation",
  64. "\passignee",
  65. "\passimilate",
  66. "\passist",
  67. "\paudible",
  68. "\paudience",
  69. "\paudio",
  70. "\paudiotape",
  71. "\paudiovisual",
  72. "\paxiomatic",
  73. "\paxis",
  74. "\paxisymmetric",
  75. "\paxle",
  76. "\paxon",
  77. "\pbamboo",
  78. "\pbanal",
  79. "\pbanana",
  80. "\pband",
  81. "\pbasilar",
  82. "\pbasilisk",
  83. "\pbasin",
  84. "\pbasis",
  85. "\pbask",
  86. "\pbedroom",
  87. "\pbedside",
  88. "\pbedspread",
  89. "\pbedspring",
  90. "\pbedstraw",
  91. "\pbenevolent",
  92. "\pbenight",
  93. "\pbenign",
  94. "\pbent",
  95. "\pbenthic",
  96. "\pbifocal",
  97. "\pbifurcate",
  98. "\pbigotry",
  99. "\pbivalve",
  100. "\pbivouac",
  101. "\pbizarre",
  102. "\pbluebill",
  103. "\pbluebird",
  104. "\pbluebonnet",
  105. "\pbluebook",
  106. "\pbluebush",
  107. "\pbookish",
  108. "\pbookkeep",
  109. "\pbooklet",
  110. "\pbookplate",
  111. "\pbookseller",
  112. "\pbrae",
  113. "\pbrag",
  114. "\pbragging",
  115. "\pbraid",
  116. "\pbrain",
  117. "\pbring",
  118. "\pbrink",
  119. "\pbriny",
  120. "\pbrisk",
  121. "\pbugle",
  122. "\pbuild",
  123. "\pbuildup",
  124. "\pbuilt",
  125. "\pbuiltin",
  126. "\pbutene",
  127. "\pbutler",
  128. "\pbutte",
  129. "\pcaliph",
  130. "\pcalisthenic",
  131. "\pcall",
  132. "\pcalumny",
  133. "\pcalypso",
  134. "\pcamera",
  135. "\pcamouflage",
  136. "\pcandlestick",
  137. "\pcapacitive",
  138. "\pcapacity",
  139. "\pcape",
  140. "\pcapella",
  141. "\pcartwheel",
  142. "\pcarve",
  143. "\pcascade",
  144. "\pcedilla",
  145. "\pceil",
  146. "\pcelandine",
  147. "\pcelebrant",
  148. "\pcelebrate",
  149. "\pchangeable",
  150. "\pchangeover",
  151. "\pchannel",
  152. "\pchant",
  153. "\pchicory",
  154. "\pchide",
  155. "\pchief",
  156. "\pchiefdom",
  157. "\pchieftain",
  158. "\pclassmate",
  159. "\pclassroom",
  160. "\pclassy",
  161. "\pclatter",
  162. "\pclattery",
  163. "\pcoachwork",
  164. "\pcoadjutor",
  165. "\pcoagulable",
  166. "\pcola",
  167. "\pcolander",
  168. "\pcolatitude",
  169. "\pcold",
  170. "\pcoleus",
  171. "\pcommit",
  172. "\pcommittable",
  173. "\pconceal",
  174. "\pconcede",
  175. "\pconceit",
  176. "\pconceive",
  177. "\pconcentrate",
  178. "\pcongener",
  179. "\pcongenital",
  180. "\pcongest",
  181. "\pcongestion",
  182. "\pcontaminant",
  183. "\pcontemplate",
  184. "\pcontemporary",
  185. "\pcontempt",
  186. "\pcool",
  187. "\pcoolant",
  188. "\pcoolheaded",
  189. "\pcoon",
  190. "\pcoop",
  191. "\pcosine",
  192. "\pcosmetic",
  193. "\pcosmic",
  194. "\pcosmology",
  195. "\pcowlick",
  196. "\pcoworker",
  197. "\pcowpea",
  198. "\pcrevice",
  199. "\pcrew",
  200. "\pcrewcut",
  201. "\pcrewel",
  202. "\pcrewman",
  203. "\pcubbyhole",
  204. "\pcube",
  205. "\pcubic",
  206. "\pcybernetics",
  207. "\pcycle",
  208. "\pcyclic",
  209. "\pcyclist",
  210. "\pdeadwood",
  211. "\pdeaf",
  212. "\pdeafen",
  213. "\pdeal",
  214. "\pdeallocate",
  215. "\pdeduce",
  216. "\pdeducible",
  217. "\pdeduct",
  218. "\pdeductible",
  219. "\pdeed",
  220. "\pdelusive",
  221. "\pdeluxe",
  222. "\pdelve",
  223. "\pdemagnify",
  224. "\pdemagogue",
  225. "\pdepute",
  226. "\pdeputy",
  227. "\pderail",
  228. "\pderange",
  229. "\pderate",
  230. "\pdeviate",
  231. "\pdevice",
  232. "\pdevil",
  233. "\pdevilish",
  234. "\pdevious",
  235. "\pdiffusive",
  236. "\pdifluoride",
  237. "\pdigest",
  238. "\pdigestible",
  239. "\pdisembowel",
  240. "\pdisgruntle",
  241. "\pdisgustful",
  242. "\pdish",
  243. "\pdishevel",
  244. "\pdockyard",
  245. "\pdoctor",
  246. "\pdoctoral",
  247. "\pdoctorate",
  248. "\pdoctrinaire",
  249. "\pdowitcher",
  250. "\pdown",
  251. "\pdowncast",
  252. "\pdowndraft",
  253. "\pdrought",
  254. "\pdrove",
  255. "\pdrown",
  256. "\pdrowse",
  257. "\pdrowsy",
  258. "\pdyspeptic",
  259. "\pdysplasia",
  260. "\pdysprosium",
  261. "\pdystrophy",
  262. "\peffluent",
  263. "\peffort",
  264. "\peffusive",
  265. "\pelution",
  266. "\pelves",
  267. "\pelysian",
  268. "\pemaciate",
  269. "\pencompass",
  270. "\pencore",
  271. "\pencounter",
  272. "\pencourage",
  273. "\pencroach",
  274. "\pentrap",
  275. "\pentrapping",
  276. "\pentreat",
  277. "\pentreaty",
  278. "\pentree",
  279. "\pergodic",
  280. "\perode",
  281. "\perodible",
  282. "\perosible",
  283. "\perosion",
  284. "\pevaporate",
  285. "\pevasion",
  286. "\pevasive",
  287. "\peven",
  288. "\pexempt",
  289. "\pexemption",
  290. "\pexercisable",
  291. "\pexercise",
  292. "\pexert",
  293. "\pexpressway",
  294. "\pexpropriate",
  295. "\pexpulsion",
  296. "\pexpunge",
  297. "\pexpurgate",
  298. "\pfair",
  299. "\pfairgoer",
  300. "\pfairway",
  301. "\pfairy",
  302. "\pfaith",
  303. "\pfederal",
  304. "\pfibula",
  305. "\pfiesta",
  306. "\pfife",
  307. "\pfifteen",
  308. "\pfifth",
  309. "\pfixate",
  310. "\pfixture",
  311. "\pfloor",
  312. "\pfloorboard",
  313. "\pfloppy",
  314. "\pfoolproof",
  315. "\pfootball",
  316. "\pfootbridge",
  317. "\pfootfall",
  318. "\pfoothill",
  319. "\pfootman",
  320. "\pfountain",
  321. "\pfountainhead",
  322. "\pfour",
  323. "\pfourfold",
  324. "\pfoursome",
  325. "\pfritillary",
  326. "\pfritter",
  327. "\pfrivolity",
  328. "\pgabardine",
  329. "\pgastronomy",
  330. "\pgate",
  331. "\pgesticulate",
  332. "\pgesture",
  333. "\pgetaway",
  334. "\pgetting",
  335. "\pgloat",
  336. "\pglob",
  337. "\pglobal",
  338. "\pgorilla",
  339. "\pgoshawk",
  340. "\pgreater",
  341. "\pgrebe",
  342. "\pgreed",
  343. "\pgreedy",
  344. "\pgreen",
  345. "\pguidance",
  346. "\pguide",
  347. "\pguidebook",
  348. "\pguideline",
  349. "\pguidepost",
  350. "\phailstorm",
  351. "\phair",
  352. "\phaircut",
  353. "\phairdo",
  354. "\phairpin",
  355. "\pharem",
  356. "\phark",
  357. "\pharm",
  358. "\pharmful",
  359. "\pharmonic",
  360. "\pheave",
  361. "\pheaven",
  362. "\pheavenward",
  363. "\pheavy",
  364. "\pheavyweight",
  365. "\phero",
  366. "\pheroic",
  367. "\phistorian",
  368. "\phistory",
  369. "\phood",
  370. "\phoodlum",
  371. "\phoofmark",
  372. "\phook",
  373. "\phubby",
  374. "\phymnal",
  375. "\phyperbola",
  376. "\pillustrious",
  377. "\pimage",
  378. "\pimaginary",
  379. "\pimposition",
  380. "\pimpossible",
  381. "\pimposture",
  382. "\pimpotent",
  383. "\pinclude",
  384. "\pincoherent",
  385. "\pincome",
  386. "\pineducable",
  387. "\pineffable",
  388. "\pineffective",
  389. "\pineffectual",
  390. "\pinfringe",
  391. "\pinfuriate",
  392. "\pinfuse",
  393. "\pinsightful",
  394. "\pinsignia",
  395. "\pinsincere",
  396. "\pinsinuate",
  397. "\pinsipid",
  398. "\pinterstitial",
  399. "\pinterval",
  400. "\pionosphere",
  401. "\piota",
  402. "\pjalopy",
  403. "\pjamboree",
  404. "\pjudge",
  405. "\pjudicature",
  406. "\pjudicial",
  407. "\pkeyword",
  408. "\pkhaki",
  409. "\pkibbutzim",
  410. "\plark",
  411. "\plarkspur",
  412. "\plarva",
  413. "\pleatherwork",
  414. "\pleave",
  415. "\pleaven",
  416. "\pliberal",
  417. "\pliberate",
  418. "\pliberty",
  419. "\pliquidate",
  420. "\plist",
  421. "\plonesome",
  422. "\plong",
  423. "\plongevity",
  424. "\plonghand",
  425. "\plonghorn",
  426. "\plunar",
  427. "\plunatic",
  428. "\plunch",
  429. "\pmaidservant",
  430. "\pmail",
  431. "\pmailbox",
  432. "\pmalice",
  433. "\pmansion",
  434. "\pmastiff",
  435. "\pmastodon",
  436. "\pmatch",
  437. "\pmatchbook",
  438. "\pmegalomaniac",
  439. "\pmetalwork",
  440. "\pmetamorphic",
  441. "\pmetaphor",
  442. "\pmillennium",
  443. "\pmiller",
  444. "\pmillet",
  445. "\pmoan",
  446. "\pmoat",
  447. "\pmonth",
  448. "\pmonument",
  449. "\pmood",
  450. "\pmuffin",
  451. "\pmuffle",
  452. "\pmyocardium",
  453. "\pmyopia",
  454. "\pneedful",
  455. "\pneedle",
  456. "\pneedlepoint",
  457. "\pnightmare",
  458. "\pnightshirt",
  459. "\pnighttime",
  460. "\pnihilism",
  461. "\pnoteworthy",
  462. "\pnothing",
  463. "\pnotice",
  464. "\pnoticeable",
  465. "\pnotify",
  466. "\pobjector",
  467. "\pobligatory",
  468. "\poblige",
  469. "\pofficious",
  470. "\poffset",
  471. "\popposition",
  472. "\poppress",
  473. "\postentatious",
  474. "\posteology",
  475. "\ppalette",
  476. "\ppalindrome",
  477. "\ppalisade",
  478. "\pparaxial",
  479. "\pparboil",
  480. "\pparcel",
  481. "\pparch",
  482. "\ppardon",
  483. "\ppathology",
  484. "\ppathway",
  485. "\ppatient",
  486. "\ppellagra",
  487. "\ppellet",
  488. "\ppelt",
  489. "\ppelvic",
  490. "\pperiwinkle",
  491. "\pperjure",
  492. "\pperjury",
  493. "\pperk",
  494. "\pphantom",
  495. "\ppharmacist",
  496. "\ppiety",
  497. "\ppigeon",
  498. "\pplacebo",
  499. "\pplaceholder",
  500. "\pplacenta",
  501. "\pplowshare",
  502. "\ppluck",
  503. "\pplug",
  504. "\ppolymorphic",
  505. "\ppolynomial",
  506. "\ppolyphony",
  507. "\ppolytechnic",
  508. "\ppostman",
  509. "\ppostmark",
  510. "\ppostmortem",
  511. "\ppreen",
  512. "\pprefabricate",
  513. "\ppreface",
  514. "\pprincess",
  515. "\pprinciple",
  516. "\pprint",
  517. "\pprompt",
  518. "\ppromulgate",
  519. "\pprone",
  520. "\pprong",
  521. "\pprovidential",
  522. "\pprovince",
  523. "\pprovision",
  524. "\ppunt",
  525. "\ppuny",
  526. "\ppupal",
  527. "\pquantum",
  528. "\pquarantine",
  529. "\pquark",
  530. "\pquarrel",
  531. "\pquiet",
  532. "\pradio",
  533. "\pradioactive",
  534. "\pradiocarbon",
  535. "\praucous",
  536. "\pravel",
  537. "\praven",
  538. "\predactor",
  539. "\predcoat",
  540. "\predden",
  541. "\preliant",
  542. "\prelic",
  543. "\prelieve",
  544. "\prescind",
  545. "\prescue",
  546. "\presemble",
  547. "\present",
  548. "\pretrovision",
  549. "\preturn",
  550. "\preveal",
  551. "\prevelation",
  552. "\prightward",
  553. "\prigid",
  554. "\prigorous",
  555. "\prill",
  556. "\prose",
  557. "\prosebud",
  558. "\prosebush",
  559. "\prosette",
  560. "\prusset",
  561. "\prust",
  562. "\prustic",
  563. "\prustle",
  564. "\psalvo",
  565. "\psame",
  566. "\psaxophone",
  567. "\pscabbard",
  568. "\pscout",
  569. "\pscowl",
  570. "\pscraggly",
  571. "\pscram",
  572. "\psecrecy",
  573. "\psecret",
  574. "\psecretarial",
  575. "\pseparate",
  576. "\pshaky",
  577. "\pshale",
  578. "\pshallot",
  579. "\pshoemaker",
  580. "\pshoestring",
  581. "\pshone",
  582. "\psideboard",
  583. "\psidecar",
  584. "\psidelight",
  585. "\psideline",
  586. "\psingsong",
  587. "\psingular",
  588. "\psinistral",
  589. "\pslander",
  590. "\pslang",
  591. "\pslant",
  592. "\pslap",
  593. "\psmile",
  594. "\psmirk",
  595. "\psmithereens",
  596. "\psmithy",
  597. "\psocial",
  598. "\psociety",
  599. "\psophistry",
  600. "\psophomore",
  601. "\psoprano",
  602. "\pspecify",
  603. "\pspecimen",
  604. "\pspecious",
  605. "\pspeckle",
  606. "\pspokesmen",
  607. "\psponge",
  608. "\psponsor",
  609. "\pspontaneity",
  610. "\pstable",
  611. "\pstableman",
  612. "\pstaccato",
  613. "\pstealthy",
  614. "\psteam",
  615. "\psteamboat",
  616. "\psteed",
  617. "\pstonewall",
  618. "\pstoneware",
  619. "\pstonewort",
  620. "\pstony",
  621. "\pstrontium",
  622. "\pstrophe",
  623. "\pstrove",
  624. "\psuccumb",
  625. "\psuch",
  626. "\psuckling",
  627. "\psuperstition",
  628. "\psupervene",
  629. "\psupervisory",
  630. "\psupine",
  631. "\psweepstake",
  632. "\psweetheart",
  633. "\pswell",
  634. "\psystematic",
  635. "\psystemic",
  636. "\ptapping",
  637. "\ptarantula",
  638. "\pteleost",
  639. "\ptelepathic",
  640. "\ptelephone",
  641. "\ptestimony",
  642. "\ptesty",
  643. "\pthieves",
  644. "\pthigh",
  645. "\pthimble",
  646. "\pthreadbare",
  647. "\ptiara",
  648. "\ptibia",
  649. "\ptick",
  650. "\pticket",
  651. "\ptickle",
  652. "\ptolerant",
  653. "\ptoll",
  654. "\ptollhouse",
  655. "\ptownhouse",
  656. "\ptownsman",
  657. "\ptoxic",
  658. "\ptoxicology",
  659. "\ptrap",
  660. "\ptrapezium",
  661. "\ptrapezoid",
  662. "\ptrip",
  663. "\ptripartite",
  664. "\ptripe",
  665. "\ptriple",
  666. "\ptriplet",
  667. "\ptumultuous",
  668. "\ptuna",
  669. "\ptundra",
  670. "\ptune",
  671. "\ptyranny",
  672. "\pupshot",
  673. "\pupstair",
  674. "\pvanguard",
  675. "\pvanilla",
  676. "\pvanish",
  677. "\pvanity",
  678. "\pvanquish",
  679. "\pvertical",
  680. "\pvertices",
  681. "\pvertigo",
  682. "\pvery",
  683. "\pvirtue",
  684. "\pviscount",
  685. "\pviscous",
  686. "\pvise",
  687. "\pvisible",
  688. "\pwail",
  689. "\pwaist",
  690. "\pwaistcoat",
  691. "\pwaistline",
  692. "\pwaterproof",
  693. "\pwatershed",
  694. "\pwaterway",
  695. "\pwatery",
  696. "\pwheat",
  697. "\pwheedle",
  698. "\pwheel",
  699. "\pwheelbase",
  700. "\pwield",
  701. "\pwiener",
  702. "\pwife",
  703. "\pwindbag",
  704. "\pwoebegone",
  705. "\pwoke",
  706. "\pwring",
  707. "\pwrinkle",
  708. "\pwrist",
  709. "\pyule",
  710. "\pzero",
  711. "\pzinc",
  712. "\pzucchini",
  713. "\pzygodactyl"
  714. };
  715.  
  716. static short    wOrder[maxWords];
  717. static short    wIndex = maxWords;
  718.  
  719.  
  720. unsigned char *
  721. PickWord (void)
  722. {
  723. short    i, j, n;
  724.  
  725.     if (wIndex >= maxWords)
  726.     {
  727.         /*
  728.          * Initialize the array with the values 0 .. maxWords-1.
  729.          * Randomize it by walking through it one element at a time,
  730.          * swapping the contents of each element with a randomly chosen
  731.          * other element.  This pretty much ensures that each element
  732.          * is swapped at least once (though not necessarily), and takes
  733.          * time linearly related to the length of the array.
  734.          */
  735.  
  736.         for (i = 0; i < maxWords; ++i)
  737.             wOrder[i] = i;
  738.         for (i = 0; i < maxWords; ++i)
  739.         {
  740.             j = BlobRand (maxWords - 1);
  741.             n = wOrder[i];
  742.             wOrder[i] = wOrder[j];
  743.             wOrder[j] = n;
  744.         }
  745.  
  746.         wIndex = 0;
  747.     }
  748.  
  749.     return (word[wOrder[wIndex++]]);
  750. }
  751.